package com.zhc.dejingapi.common.utils;

import org.springframework.context.annotation.Configuration;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author zhc
 * @date 2024年09月14日 13:49
 */
@Configuration
public class StringToLocalDateTimeUtils {

    public LocalDateTime stringToLocalDateTime(String dateTimeStr) {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
        LocalDateTime localDateTime = LocalDateTime.parse(dateTimeStr, formatter);
        return localDateTime;
    }
    public LocalDateTime stringToLocalDateTimeYYMMDD(String dateTimeStr) {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        LocalDateTime localDateTime = LocalDate.parse(dateTimeStr, formatter).atStartOfDay();
        return localDateTime;
    }
}
